package com.fita.entity.order;

import com.demo2do.core.format.PersistentFormat;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import javax.persistence.*;


/**
 * 订单详情
 * 
 * @author 宋剑宏
 *
 */
@Entity
@Table(name = "order_details")
@PersistentFormat
@JsonIgnoreProperties(value={"hibernate_lazy_initializer","handler","fieldHandler"})
public class OrderDetails {

    @Id
    @GeneratedValue
    private Long id;
    
    private String setMeal; //套餐名称
    
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private CustomerInfo customerInfo;//客户信息
    
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private OrderExtras extras;//附加消息
    
    @ManyToOne(optional = false)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private CarInfo carInfo; // 车辆详细信息
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    /**
     * The default constructor
     */
    public OrderDetails() {
    }
    
    public OrderDetails(String setCode, CustomerInfo customerInfo,
                        CarInfo carInfo) {
        this.setMeal = setCode;
        this.customerInfo = customerInfo;
        this.carInfo = carInfo;
    }
    
    public OrderDetails init() {
        this.disabled = false;
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the setMeal
     */
    public String getSetMeal() {
        return setMeal;
    }

    /**
     * @return the customerInfo
     */
    public CustomerInfo getCustomerInfo() {
        return customerInfo;
    }

    /**
     * @return the extras
     */
    public OrderExtras getExtras() {
        return extras;
    }

    /**
     * @return the carInfo
     */
    public CarInfo getCarInfo() {
        return carInfo;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param setMeal the setMeal to set
     */
    public void setSetMeal(String setMeal) {
        this.setMeal = setMeal;
    }

    /**
     * @param customerInfo the customerInfo to set
     */
    public void setCustomerInfo(CustomerInfo customerInfo) {
        this.customerInfo = customerInfo;
    }

    /**
     * @param extras the extras to set
     */
    public void setExtras(OrderExtras extras) {
        this.extras = extras;
    }

    /**
     * @param carInfo the carInfo to set
     */
    public void setCarInfo(CarInfo carInfo) {
        this.carInfo = carInfo;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
